package com.study.controller;

import com.study.entity.User;
import com.study.service.UserService;
import com.study.util.BeanFactory;

/**
 * @Author chenyeqing
 * @Date 2021/9/13 20:46
 */
public class UserController {

    public static void main(String[] args) {

        // 后半部分有耦合，如果来了个新的实现类 new UserServiceImplNew(); 就需要改动这里的代码，不符合开闭原则
        // UserService userService = new UserServiceImpl();
        // 而是用工厂模式，就可以解掉这里的耦合
        UserService userService = (UserService) BeanFactory.getBean("userService");
        User user = new User("张三", "123456");

        userService.register(user);

        userService.login("张三", "123456");

    }
}
